package com.learn.demo.netty.io;


import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;

/**
 * 入站解码处理器
 *
 * @author banjiawei
 * @date 2021/08/03
 */
public class MyServerInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel socketChannel) throws Exception {
        ChannelPipeline pipeline = socketChannel.pipeline();
        //对入站的handler进行解码
        pipeline.addLast(new MyByteToLongDecoder());
        //对出站的handler进行编码
        pipeline.addLast(new MyLongToByteEncoder());
        pipeline.addLast(new MyServerHandler());
    }
}
